<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <base href="<?php echo base_url();?>"/>
    <title><?php echo $title;?></title>
    <link href="style/base.css" rel="stylesheet" type="text/css" />
    <link href="style/common.css" rel="stylesheet" type="text/css" />
    <link href="style/houtai.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" href="uploadify/uploadify.css">
    <script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>

    <script src="uploadify/jquery.uploadify.min.js" type="text/javascript"></script>

    <script src="js/organictabs.jquery.js"></script>
    <script type="text/javascript" src="js/Common.js"></script>
    <script type="text/javascript" src="js/Validation.js"></script>
    <script type="text/javascript" src="jscript/WdatePicker.js"></script>
    <script type="text/javascript" src="js/jquery.form.js"></script>
    <script type="text/javascript" src="js/jquery.blockUI.js"></script>


    <!--[if IE 6]>
    <script type="text/javascript" language="javascript" src="js/ie6/DD_belatedPNG_0.0.8a-min.js"></script>
    <script type="text/javascript" language="javascript">
        DD_belatedPNG.fix('.logo img,.footer_logo img');
    </script>
    <![endif]-->
    <script type="text/javascript" language="javascript">

        <?php $timestamp = time();?>
        $(function() {
            $('#file_upload').uploadify({
                'formData'     : {
                    'timestamp' : '<?php echo $timestamp;?>',
                    'token'     : '<?php echo md5('unique_salt' . $timestamp);?>'
                },
                'swf'      : '<?php echo base_url();?>uploadify/uploadify.swf',
                'uploader' : '<?php echo base_url();?>uploadify/uploadify.php',
                'onInit': function () {
                    $("#file_upload-queue").hide();
                },
                'onQueueComplete' : function(queueData) {
                    alert('上传成功');
                },
                'buttonImage': 'images/sczp_inp.jpg',
                'onUploadSuccess' : function(file, data, response) {
                    savePic(data);
                }
            });
        });
        $(function(){
            $("#btnCreateAlbum").bind("click",function(){$(this).hide();$("#spanCreateAlbum").show();});
            $("#btnCancelAlbum").bind("click",function(){$("#btnCreateAlbum").show();$("#spanCreateAlbum").hide();});
            $("#txtAlbumName").bind("blur",check);
            $("#btnSaveAlbum").bind("click",save);
            //loadAlbums();
            loadAlbumsLink();

        });
        function savePic(url){
            var params= {
                albumid:$("#selAlbum").val(),
                url:url
            };

            $.ajax({
                type:"post",
                url:"index.php/manage/saveAlbumDetail",
                dataType:"json",
                data:params,
                async:false,
                success:function(data){
                    loadAlbumsLink();
                }
            });
        }
        function save(){
            if(check()==false)
                return;
            var name = $.trim($("#txtAlbumName").val());
            var params = {name:name};
            $.ajax({
                type:"post",
                url:"index.php/manage/saveAlbumName",
                dataType:"json",
                data:params,
                success:function(data){
                    if(data.ReturnCode==1){
                        $("#txtAlbumName").val('');
                        ClearError("txtAlbumName");
                        $("#spanCreateAlbum").hide();
                        $("#btnCreateAlbum").show();
                        loadAlbumsLink();
                    }else{
                        alert('保存失败：'+data.Msg);
                    }
                }
            });
        }
        function loadAlbums(){
            var sel = $("#selAlbum").val();
            $.ajax({
                type:"post",
                url:"index.php/manage/loadAlbums",
                dataType:"json",
                success:function(data){
                    $("#ulAlbum").html(data.album);
                    $("#selAlbum").html(data.albumNames);
                    $("#selAlbum").val(sel);
                }
            });
        }
        function loadAlbumsLink(){
            $.ajax({
                type:"post",
                url:"index.php/manage/loadAlbumsLink",
                dataType:"json",
                success:function(data){
                    $('#xiangce').html(data.album);
                    $("#selAlbum").append(data.albumNames);
                }
            });
        }
        function check(){
            var name = $.trim($("#txtAlbumName").val());
            if(IsEmpty(name)){
                SetError("txtAlbumName","请输入专辑名称");
                return false;
            }
            var len = name.length;
            if(len<=0 || len>20){
                SetError("txtAlbumName","最多20字符");
                return false;
            }
            isok=true;
            var params = {name:name};

            $.ajax({
                type:"post",
                url:"index.php/manage/checkExistsName",
                dataType:"json",
                data:params,
                async:false,
                success:function(data){
                    if(data.ReturnCode!=1){
                        SetError("txtAlbumName",data.Msg);
                        isok=false;
                    }
                }
            });
            if(isok==false)
                return false;
            SetOK("txtAlbumName");
            return true;
        }
    </script>
    <style type="text/css">
    .uploadify-button {
        background-color: transparent;
        border: none;
        padding: 0;
    }
    .uploadify:hover .uploadify-button {
        background-color: transparent;
    }
</style>
</head>

<body>
<!-- head S-->
<?php
include 'header.php';
?>
<!-- head E-->

<div class="houtai_content mt_10 clearfix">
    <!-- 侧栏 开始 -->
    <?php
    include 'member_left.php';
    ?>
    <!-- 侧栏 结束 -->

    <!-- 用户中心首页 S -->
    <!-- 相册上传照片 S -->
    <div class="houtai_main">
        <div class="houtai_xiangce">
            <div class="houtai_main_tit">用户中心—相册管理</div>
            <div class="houtai_xiangce_cnt">
                <!-- 相册管理 开始 -->

                <div class="xiangce">
                    <ul id="xiangce">

                    </ul>
                </div>
                <div class="xiangce"><span class="b">上传照片</span></div>
                <div class="xiangce">
                    <span class="font_s12">上传至：</span>
                    <select name="" style="width:200px; height:25px;" id="selAlbum">
                    </select>

                    <span id="spanCreateAlbum" style="display: none"> 专辑名称：
                        <input type="text" id="txtAlbumName" style="width: 160px; height: 22px;" />
                        <img id="btnSaveAlbum" class="link" style="vertical-align: middle" src="images/bc_inp.jpg" />
                        <img id="btnCancelAlbum" class="link" style="vertical-align: middle" src="images/fq_inp.jpg" />
                    </span>
                    <img id="btnCreateAlbum" class="link" style="vertical-align: middle" src="images/cjzj_inp.jpg" />
                    <div class="filter_inpa">
                        <input id="file_upload" name="file_upload" type="file" multiple="true">
                    </div>
                </div>




                <!-- 相册管理 结束 -->
            </div>
        </div>
    </div>
    <!-- 相册上传照片 E -->
</div>
    <!-- 用户中心首页 E -->
</div>

<!-- 底部 S -->
<?php include 'footer.php';?>
<!-- 底部 E -->
</body>
</html>
